<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title>新增收货地址</title>
		<script src="js/mui.min.js"></script>
		<link href="css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" type="text/css" href="css/add_site.css"/>
		<link rel="stylesheet" type="text/css" href="css/public.css"/>
		<script type="text/javascript" charset="utf-8">
			mui.init();
		</script>
		<style type="text/css">
			input{padding-bottom: 30px;}
			.mui-icon-clear{top: 20px!important;}
		</style>
	</head>

	<body>
	<div id="headerNav"></div>
	<!--------填写新增地址信息----------->
		<div class="mui-content" style="background:white;margin-top: 45px;">
			<div class="mui-input-group">
				<div class="mui-input-row" style="height:60px;line-height: 60px;">
					<label style="height:60px;line-height: 60px;">收货人</label>
					<input type="text" class="mui-input-clear" placeholder="请输入名字" id="username">
				</div>
				<div class="mui-input-row" style="height:60px;line-height:60px;">
					<label style="height:60px;line-height: 60px;">手机号码：</label>
					<input type="text" class="mui-input-clear" placeholder="请输入您的手机号码" id="mobile">
				</div>
				<div class="mui-input-row" style="height:60px;line-height:60px;">
					<label style="height:60px;line-height: 60px;">所在城市：</label>
					<input type="text" class="mui-input-clear" placeholder="填写您所在的城市" id="city">
				</div>
				<div class="mui-input-row" style="height:60px;line-height:60px;">
					<label style="height:60px;line-height: 60px;">收货地址：</label>
					<input type="text" class="mui-input-clear" placeholder="填写所在的街道/小区" id="address">
				</div>
			</div>
	<!--------保存收货信息----------->
			<div class="mui-button-row" style="background:white;margin-top:22px;">
				<button type="button" class="mui-btn mui-btn-primary" style="width:95%;height:50px;background:#5763FF;" id="btn">保存收货信息</button>
			</div>
		</div>
	</body>
	<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
	<script type="text/javascript">
		$('#headerNav').load('header.html',function(){
			$('header h1').html('新增收货地址');
		});
	</script>
	<script type="text/javascript">
		
	$("#btn").click(function(){
	function GetQueryString(name) {
			var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
			var r = window.location.search.substr(1).match(reg);
			if(r != null) return unescape(r[2]);
			return null;
		}
		var checked = GetQueryString("id");
		var a = localStorage.state;
		var b = localStorage.data;
		var username = $("#username").val();
		var mobile = $("#mobile").val();
		var city = $("#city").val();
		var address = $("#address").val();
			$.ajax({
				type:"post",
				url:"http://mall.itcn99.com/i/index/add_address",
				async:true,
				dataType:'jsonp',
				data:{
					"uid":b,
					"username":username,
					"mobile":mobile,
					"city":city,
					"address":address,
				},
				success:function(data){
					console.log(data)
					var state = data.state;
					if(state == 1){
						mui.alert("","添加成功",function(){
							window.location.href="productDetails.html?id="+checked;
						})
					}else{
						mui.alert("","添加失败");
					}
					
				}
			});
	})		
	</script>
</html>